package com.zhi.Exam.controller;


import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhi.Exam.model.ExamModel;
import com.zhi.Exam.service.ExamService;

@Controller
@RequestMapping("exam")
public class ExamController {
	
	@Autowired
	ExamService service;
	
	
	
	@RequestMapping(value="index.do")
	public String   index(Model model){
		
		List<ExamModel> examModels = service.selectAll();
		
		model.addAttribute("examModels",examModels);
		
		return "test";
	}
	
	@RequestMapping(value="index1.do")
	public String   index1(Model model){
		
		List<ExamModel> examModels = service.selectAll();
		
		model.addAttribute("examModels",examModels);
		
		return "test1";
	}
	@ResponseBody
	@RequestMapping(value="index2.do",method=RequestMethod.POST)
	public Object   index2(Model model,String shujus,HttpServletRequest request){
		
		String Url =request.getServletContext().getContextPath();
		HashMap map = new HashMap<>();
		
		map.put("result",true);
		map.put("url",Url);
		
		System.out.println(Url);
		System.out.println(shujus);
		if (shujus==null||shujus=="") {
			map.put("result",false);
			map.put("message","你选择的数据为空");
		}
		
		
		return map;
	}

}
